package com.tencent.miniproject.utils;

import android.content.Context;

import com.tencent.miniproject.constants.Constant;

public class UserInfoUtil {

    public static String getUserHeadUrl(Context context){
        if ("".equals(Constant.USER_HEAD_URL)){
            Constant.USER_HEAD_URL = context.getSharedPreferences("appBase", Context.MODE_PRIVATE).getString("headUrl", "");
        }
        return Constant.USER_HEAD_URL;
    }

    public static void setUserHeadUrl(Context context, String headUrl){
        context.getSharedPreferences("appBase", Context.MODE_PRIVATE).edit().putString("headUrl", headUrl).apply();
    }

    public static String getUserName(Context context){
        if ("".equals(Constant.USER_NAME)){
            Constant.USER_NAME = context.getSharedPreferences("appBase", Context.MODE_PRIVATE).getString("userName", "");
        }
        return Constant.USER_NAME;
    }

    public static void setUserName(Context context, String userName){
        context.getSharedPreferences("appBase", Context.MODE_PRIVATE).edit().putString("userName", userName).apply();
    }

}
